@extends('backend/layouts/default')
@section('title')
<?= !empty($data['category']->id) ? "Sửa chuyên mục" : "Thêm mới chuyên mục"; ?>
@stop
@section('content')
<h3>
    <span
        class="glyphicon glyphicon-user"></span> <?= !empty($data['category']->id) ? "Sửa chuyên mục" : "Thêm mới chuyên mục"; ?>
</h3>
@if(Session::has('success'))
<h3>{{Session::get('success')}}</h3>
@endif
<ul class="nav nav-tabs" style="margin: 15px 0">
    <li class="active"><a href="#tab-general" data-toggle="tab">Thông tin chung</a></li>
    @for($i = 1; $i <= 10; $i++)
    <li><a href="#level-{{$i}}" data-toggle="tab">Level {{$i}}</a></li>
    @endfor
</ul>
<form class="form-horizontal" action="<?= route('create/categories/admin') ?>" method="post">
    <input type="hidden" value="<?= $data['category']->id ?>" name="data[Category][id]" id="data[Category][id]"/>

    <div class="row">
        <div class="col-md-9">
            <div class="tab-content">
                <div class="tab-pane active" id="tab-general">
                    <div class="form-group <?= $errors->has('title') ? 'error' : '' ?>">
                        <label class="control-label col-sm-4">Tiêu đề</label>

                        <div class="col-sm-8">
                            <input type="text" name="data[Category][title]" id="data[Category][title]"
                                   class="form-control"
                                   value="<?= $data['category']->title ?>"/>
                            <?= $errors->first('title', '<span class="help-inline">:message</span>') ?>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4">Trạng thái</label>

                        <div class="col-sm-8">
                            <?= Form::select('data[Category][status]', array('on' => 'Hiển thị', 'off' => 'Không hiển thị'), Input::old('data[Category][status]', $data['category']->status), array('class' => 'form-control')) ?>
                        </div>
                    </div>
                    <div class="form-group">
                        <lable class="control-label col-sm-4">
                            Mô tả
                        </lable>
                        <div class="col-sm-8">
                            {{Form::textarea('data[Category][description]',Input::old('data[Category][description]',$data['category']->description),array('class'=>'form-control
                            ckeditor'))}}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4">
                            Video
                        </label>
                        <div class="col-sm-8">
                            {{ Form::text('data[Category][exam_video]',Input::old('data[Category][exam_video]',$data['category']->exam_video),array('class'=>'form-control'))}}
                        </div>
                    </div>

                </div>
                @for($i = 1; $i<=10; $i++)
                <div class="tab-pane" id="level-{{$i}}">
                    {{ Form::hidden('data[Levels]['.$i.'][id]',Input::old('data[Levels]['.$i.'][id]',!empty($data['levels'][$i-1])?$data['levels'][$i-1]->id :""))}}
                    <div class="form-group">
                        <label class="control-label col-sm-4">
                            Tiêu đề
                        </label>
                        <div class="col-sm-8">
                            {{ Form::text('data[Levels]['.$i.'][title]',Input::old('data[Levels]['.$i.'][title]',!empty($data['levels'][$i-1])?$data['levels'][$i-1]->title:""),array('class'=>'form-control'))}}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4">
                            Mô tả
                        </label>
                        <div class="col-sm-8">
                            {{ Form::textarea('data[Levels]['.$i.'][description]',Input::old('data[Levels]['.$i.'][description]',!empty($data['levels'][$i-1])?$data['levels'][$i-1]->description:""),array('class'=>'ckeditor form-control'))}}
                        </div>
                    </div>
                    <div class="form-group"><label class="control-label col-sm-4">
                            Quyền lợi
                        </label>
                        <div class="col-sm-8">
                            {{ Form::textarea('data[Levels]['.$i.'][award]',Input::old('data[Levels]['.$i.'][award]',!empty($data['levels'][$i-1])?$data['levels'][$i-1]->award:""),array('class'=>'ckeditor form-control'))}}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4">
                            Các vấn đề tiêu biểu
                        </label>
                        <div class="col-sm-8">
                            {{ Form::textarea('data[Levels]['.$i.'][notes]',Input::old('data[Levels]['.$i.'][notes]',!empty($data['levels'][$i-1])?$data['levels'][$i-1]->notes:""),array('class'=>'ckeditor form-control'))}}
                        </div>
                    </div>

<!--                    <div class="form-group">-->
<!--                        <label class="control-label col-sm-4">-->
<!--                            Bài dự thi tiêu điểm-->
<!--                        </label>-->
<!--                        <div class="col-sm-8">-->
<!--                            {{ Form::text('data[Levels]['.$i.'][exam_video]',Input::old('data[Levels]['.$i.'][exam_video]',!empty($data['levels'][$i-1])?$data['levels'][$i-1]->exam_video:""),array('class'=>'form-control'))}}-->
<!--                        </div>-->
<!--                    </div>-->

                </div>
                @endfor
            </div>
            <div class="control-group" align="right">
                <div class="controls">
                    <a class="btn btn-link" href="{{ route('categories/admin') }}">Hủy</a>
                    <button type="submit" class="btn btn-success">Lưu</button>
                </div>
            </div>
        </div>
    </div>
</form>
@stop